<template>
  <view>
    <cu-custom :bgColor="'bg-' + theme.backgroundColor" :isBack="true">
      <block slot="backText">返回</block>
      <block slot="content"> 扫描二维码</block>
    </cu-custom>
    <view class="list">
      <view class="item">
        <view class="title"> 处方信息 </view>
        <view class="row">
          <text class="key">医院id</text>
          <text class="val">{{ hospitalObj.hospitalId }}</text>
        </view>
        <view class="row">
          <text class="key">医院名称</text>
          <text class="val">{{ hospitalObj.hospitalName }}</text>
        </view>
        <view class="row">
          <text class="key">处方号</text>
          <text class="val">{{ hospitalObj.presNo }}</text>
        </view>
        <view class="row">
          <text class="key">临床诊断</text>
          <text class="val">{{ hospitalObj.diagnosis }}</text>
        </view>
        <view class="row">
          <text class="key">科室名称</text>
          <text class="val">{{ hospitalObj.department }}</text>
        </view>
        <view class="row">
          <text class="key">服法用量</text>
          <text class="val">{{ hospitalObj.dosage }}</text>
        </view>
        <view class="row">
          <text class="key">药品类型</text>
          <text class="val">{{
            hospitalObj.presType == "1" ? "中药" : "颗粒剂"
          }}</text>
        </view>
        <view class="row">
          <text class="key">是否代煎</text>
          <text class="val">{{
            hospitalObj.isDj == 1 ? "代煎" : "不代煎"
          }}</text>
        </view>
        <view class="row">
          <text class="key">付数</text>
          <text class="val">{{ hospitalObj.amount }}</text>
        </view>
        <view class="row">
          <text class="key">天数</text>
          <text class="val">{{ hospitalObj.days }}</text>
        </view>
        <view class="row">
          <text class="key">药品金额</text>
          <text class="val">{{ hospitalObj.medicinePrice }}</text>
        </view>
        <view class="row">
          <text class="key">备注</text>
          <text class="val">{{ hospitalObj.remark }}</text>
        </view>
      </view>
      <view class="item">
        <view class="title">患者信息</view>
        <view class="row">
          <text class="key">患者姓名</text>
          <text class="val">{{ hospitalObj.userName }}</text>
        </view>
        <view class="row">
          <text class="key">性别</text>
          <text class="val">{{ hospitalObj.sex == 1 ? "男" : "女" }}</text>
        </view>
        <view class="row">
          <text class="key">医保类型</text>
          <text class="val">{{hospitalObj.medicalInsurance==1?'医保':'非医保' }}</text>
        </view>
        <view class="row">
          <text class="key">就诊号</text>
          <text class="val">{{ hospitalObj.patientNo }}</text>
        </view>
    
      </view>
      <view
        class="item"
        v-for="(item, index) in hospitalObj.drugChineseList"
        :key="index"
      >
        <view class="title">药品列表{{ index + 1 }}</view>
        <view class="row">
          <text class="key">药品编码</text>
          <text class="val">{{ item.spuCode }}</text>
        </view>
        <view class="row">
          <text class="key">药品名称</text>
          <text class="val">{{ item.medicineName }}</text>
        </view>
        <view class="row">
          <text class="key">数量</text>
          <text class="val">{{ item.qty }}</text>
        </view>
        <view class="row">
          <text class="key">单位</text>
          <text class="val">{{ item.unit }}</text>
        </view>
        <view class="row">
          <text class="key">药品备注</text>
          <text class="val">{{ item.memo }}</text>
        </view>
      </view>
      <view class="item">
        <view class="title">物流信息</view>
        <view class="row">
          <text class="key">配送方式</text>
          <text class="val">{{
            hospitalObj.deliveryWay == "1" ? "普通快递" : "上门自提"
          }}</text>
        </view>
        <view class="row">
          <text class="key">收件人</text>
          <text class="val">{{ hospitalObj.receiverName }}</text>
        </view>
        <view class="row">
          <text class="key">收件人电话</text>
          <text class="val">{{ hospitalObj.receiverPhone }}</text>
        </view>
        <view class="row">
          <text class="key">收件人地址</text>
          <text class="val">{{ hospitalObj.receiverAddress }}</text>
        </view>
      </view>
    </view>
   
  </view>
</template>
<script>
const app = getApp();
import api from "utils/api";

export default {
  data() {
    return {
      theme: app.globalData.theme, //全局颜色变量
      hospitalObj: {},
    };
  },
  methods: {
    save() {
      if (
        this.hospitalObj.drugChineseList &&
        this.hospitalObj.drugChineseList.length
      ) {
        this.hospitalObj.drugChineseList.forEach((el) => {
          el.qty -= 0;
        });
      }

      api.qrcodeSave(this.hospitalObj).then((res) => {
        uni.showToast({
          title: "操作成功",
          icon: "success",
          mask: true,
        });
        uni.navigateBack({ delta: 1 });
      });
    },
  },
  onShow() {
    this.hospitalObj = uni.getStorageSync("hospitalObj");
    console.log(this.hospitalObj);
  },
};
</script>
<style lang="scss" scoped>
.list {
  margin-bottom: 60rpx;
  .item {
    background-color: #fff;
    margin: 32rpx;
    border-radius: 16rpx;
    padding: 32rpx;
    .row {
      padding: 32rpx;
      border-bottom: 2rpx solid #eaeeef;
      display: flex;
      align-items: center;
      justify-content: space-between;
    }
    .title {
      font-size: 30rpx;
      font-weight: 500;
      margin-bottom: 16rpx;
    }
  }
}
.save {
  margin: 32rpx;
  padding-bottom: 32rpx;
}
</style>
